package com.itheima.capsulation;

public class Student {
    String name;
    int age;
    char sex;


    //1.无参数构造器：名称与类名一致 不传参为默认构造器
    public Student() {

        System.out.println("默认无参构造器");
    }

    //2.有参数构造器
    public Student(String name, int age) {
        System.out.println(this);
        System.out.println("有参构造器");
        this.name = name;
        this.age = age;
    }

    //3.
    public Student(String name, int age, char sex) {
        System.out.println("有参数构造器");
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public void print() {
        System.out.println(this.name + "的年龄为" + this.age);
    }

    //封装的设计思想 :类中所有成员变量都应该这么做，只能在本类中直接访问，其他地方不能直接访问
    private String tel;
    public String getTel() {
        return tel;
    }
    public void setTel(String tel) {
        this.tel = tel;
    }

}
